package com.itheima.mapper;

import com.itheima.pojo.OrderSetting;
import com.itheima.vo.OrderSettingVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Date;

@Mapper
public interface OrderSettingMapper {
    /**
     * 根据预约日期修改预约人数
     * @param orderSetting
     */
    @Update("update t_ordersetting set number = #{number}, reservations = #{reservations} where orderDate = #{orderDate}")
    void editNumberByOrderDate(OrderSetting orderSetting);

    /**
     * 根据预约日期查询预约设置
     *
     * @param beginDate
     * @param endDate
     * @return
     */
    @Select("select * from t_ordersetting where orderDate between #{beginDate} and #{endDate}")
    ArrayList<OrderSetting> getOrderSettingByMonth(LocalDate beginDate, LocalDate endDate);

    /**
     * 插入预约设置
     * @param orderSetting
     */
    @Insert("insert into t_ordersetting(orderDate, number) values(#{orderDate}, #{number})")
    void insert(OrderSetting orderSetting);

    /**
     * 根据预约日期查询预约设置
     * @param orderDate
     * @return
     */
    @Select("select * from t_ordersetting where orderDate = #{orderDate}")
    OrderSetting findByOrderDate(Date orderDate);
}
